package com.itany.corejava.day13;

import javafx.scene.input.DataFormat;

import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MyLs {
    public static void main(String[] args) throws IOException {


        File file=null;

        if(args.length>0){
            file=new File(args[0]);
        }else{
            file=new File(".");
        }

        if(file.exists()==false||file.isDirectory()==false){
            System.out.println("目录不存在");
            System.exit(0);
        }


        System.out.println(file.getCanonicalPath());


        File[] fs=file.listFiles();

        for (File f : fs) {
            if(f.isDirectory()){
                System.out.print("dir\t");
            }else{
                System.out.print("   \t");
            }

            DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            long l=f.lastModified();

            Date d=new Date(l);
            System.out.print(format.format(d)+"\t");

            System.out.print(f.length()+"\t");

            System.out.println(f.getName());
        }





    }
}
